<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";

export default {
  name: "APIcommonrelizhanlist",
  components: {},
  data() {
    return {
      hpObjArr: [],
      pids: [],
    };
  },
  computed: {},
  watch: {
    "$store.state.daping.bigScreen": {
      handler: function (n, o) {
        let n_tmp = n;
        let g_bigscreen_data_arr = n_tmp.filter((item) => {
          if (item.attrName == "station_pids") {
            return true;
          }
        });
        var hpObjArr = [];
        var hpPidArr = [];
        var pidStrArr = g_bigscreen_data_arr[0].attrValue.split(","); //【2019年12月2日】在大屏配置页面勾选的热源 并且按照顺序传输过来
        for (var i = 0; i < pidStrArr.length; i++) {
          // var type = pidStrArr[i].split("@@")[0];
          this.pids.push(pidStrArr[i].split("@@")[1]);
          var pid = pidStrArr[i].split("@@")[1];
          var name = pidStrArr[i].split("@@")[2];
          hpPidArr.push(pid);
          hpObjArr.push({
            pid: pid,
            name: name,
          });
        }
        this.hpObjArr = hpObjArr;
      },
    },
  },
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APIcommonrelizhanlist"] !=
        undefined
      ) {
        clearInterval(
          this.$store.state.daping.intervalArr["APIcommonrelizhanlist"][0]
            .interval
        );
      }

      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);

      this.$store.state.daping.intervalArr["APIcommonrelizhanlist"] = [
        { interval: interval },
      ];
    },

    loadData() {
      if (this.hpObjArr == []) {
        return;
      }
      let formdata = new FormData();
      formdata.append("search", `&pid in (${this.pids.join(",")})`);
      // 查询热源监控
      axios
        .post("/model/substationMonitor?&pageSize=300&pageNum=1", formdata)
        .then((rs) => {

        });
    },
  },
};
</script>
<style lang='scss' scoped>
</style>